<?php
Yii::app()->clientScript->registerScript(__CLASS__.'#DisableStatus', "\$('.grid-view .status-column.default a.active').live('click', function(){return false;})");
?>

<?php $grid = $this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'site-url-grid',
	'dataProvider'=>$model->search(),
	'filter'=>$model,
    'selectableRows'=>2,
    'selectionChanged'=>"updateSelectors",
	'columns'=>array(
		'url',
        array(
            'name'=>'status',
            'type'=>'raw',
            'value'=>'CHtml::link($data->statusText, array("statusUrl", "ids[]"=>$data->id, "value"=>$data->status ? 0 : 1), array("class"=>($data->status ? "active" : "")))',
            'filter'=>false,
            'cssClassExpression'=>'$data->default ? "default" : ""',
            'htmlOptions'=>array(
                'class'=>'status-column'
            )
        ),
        array(
            'name'=>'default',
            'type'=>'raw',
            'value'=>'CHtml::link("Set default", "#", array("class"=>($data->default ? "default" : "")))',
            'filter'=>false,
            'htmlOptions'=>array(
                'class'=>'set-default-column'
            )
        ),
        array(
            'name'=>'creation_datetime',
            'value'=>'Yii::app()->getDateFormatter()->formatDateTime(strtotime($data->creation_datetime))',
            'filter'=>false,
            'htmlOptions'=>array(
                'class'=>'datetime-column'
            )
        ),
        array(
            'name'=>'last_update',
            'value'=>'Yii::app()->getDateFormatter()->formatDateTime(strtotime($data->last_update))',
            'filter'=>false,
            'htmlOptions'=>array(
                'class'=>'datetime-column'
            )
        ),
		array(
			'class'=>'CButtonColumn',
            'template'=>'{update} {delete}',
            'deleteButtonUrl'=>'Yii::app()->controller->createUrl("/Core/service/ajax", array("SID"=>"Cms.siteUrl.delete", "ids"=>$data->id))',
            'updateButtonUrl'=>'Yii::app()->controller->createUrl("updateUrl", array("id"=>$data->id, "site_id"=>$data->site_id, "layout"=>"popup"))',
            'cssClassExpression'=>'$data->default ? "default" : ""',
		),
	),
)); 

//echo CHtml::link('Create Site Url', array('addUrl'));
/*if ($grid->dataProvider->ItemCount) {
    $this->menu[] = array(
        'label' => 'Delete selected items',
        'url'=>$this->createUrl('delete'), 'linkOptions' => array('onclick'=>'return multipleDelete("site-url-grid",this.href)'
    ));
}*/
echo CHtml::link('Create Site Url', array('addUrl', 'site_id'=>$siteId, 'layout'=>'popup'), array('class'=>'add-url'));
?>